find sum of values in a column that corresponds to unique vallues in another coulmn python

38

find sum of values in a column that corresponds to unique vallues in another coulmn python -

group = df.groupby('author')

df2 = group.apply(lambda x: x['subreddit'].unique())

# Alternatively, same thing as a one liner:
# df2 = df.groupby('author').apply(lambda x: x['subreddit'].unique())

Comments

Submit
0 Comments